// side, content - height
var _setHeight = function(){
	var sideH = $('.side-menu').height();
	var contH = $('.cont').height();
	var wHeight = $(window).outerHeight(true);
	if (wHeight > contH && wHeight > sideH){
		$('body').css('overflow-x','hidden');
		$('.cont').css('min-height', wHeight+'px');
		$('.side-menu').css('min-height',wHeight+'px');
	}else if (wHeight > contH && wHeight < sideH){
		$('body').css('overflow-x','hidden');
		$('.cont').css('min-height', sideH+100+'px');
		$('.side-menu').css('min-height',sideH+100+'px');
		
	}else if (wHeight < contH && contH > sideH){
		$('body').css('overflow-x','hidden');
		$('.cont').css('min-height', contH+'px');
		$('.side-menu').css('min-height',contH+'px');
	}
};

// slide menu
var _slideContent = function(){
	$('#HDmenuSlide').on('click', function(){
		$('.wrap').toggleClass('slide');
	});
};

// tab Casting
var _tabCast = function(){
	$('.tab-casting a').on('click', function(){
		$('.tg-c .tab-cont').hide();
		$('.tg-c .tab-cont').eq($(this).index()).show();
		$('.tab-casting a').removeClass('current');
		$('.tab-casting a').eq($(this).index()).addClass('current');
		return false;
	});
};

// toggle content
var _toggleCont = function(){
	$.each($('.tg-t'), function(){
		var $this = $(this);
		$this.on('click', function(){

			if ($this.parents('.item').hasClass('open')) {
				$this.parents('.item').removeClass('open');
				$this.parents('.item').find('.tg-c').slideUp();
				return false;
			}

			$('.toggle-content .tg-c').hide();
			$('.toggle-content .item').removeClass('open');
			$this.parents('.item').addClass('open');
			$this.parents('.item').find('.tg-c').slideDown();

			$('.cont').css('height', 'auto');
			$('.cont').css('min-height', $('.side-menu').height());
		});
	});
};

$(window).load(function(){
	_slideContent();
	_toggleCont();
	_tabCast();
	_setHeight();
});

$('.wrap').load(function(){
	_setHeight();
});

$(window).on('resize orientation', function(){
	_setHeight();
});